using dtPolyRef = System.UInt32;

namespace Recast
{
	public unsafe partial class RecastGlobal
	{
		public unsafe partial class dtQueryFilter
		{
			public float* m_areaCost;// [DT_MAX_AREAS];
			public ushort m_includeFlags;
			public ushort m_excludeFlags;
			public dtQueryFilter()
			{
				m_includeFlags = 0xffff;
				m_areaCost = rcNewArray<float>(DT_MAX_AREAS, rcAllocHint.RC_ALLOC_PERM);
				for (int i = 0; i < DT_MAX_AREAS; ++i)
					m_areaCost[i] = 1.0f;
			}
			~dtQueryFilter()
			{
				rcFree(m_areaCost);
			}
			public float getAreaCost(int i)
			{
				return m_areaCost[i];
			}
			public void setAreaCost(int i, float cost)
			{
				m_areaCost[i] = cost;
			}
			public ushort getIncludeFlags()
			{
				return m_includeFlags;
			}
			public void setIncludeFlags(ushort flags)
			{
				m_includeFlags = flags;
			}
			public ushort getExcludeFlags()
			{
				return m_excludeFlags;
			}
			public void setExcludeFlags(ushort flags)
			{
				m_excludeFlags = flags;
			}
			public bool passFilter(dtPolyRef @ref, dtMeshTile* tile, dtPoly* poly)
			{
				return (poly->flags & m_includeFlags) != 0 && (poly->flags & m_excludeFlags) == 0;
			}
			public float getCost(float* pa, float* pb, dtPolyRef prevRef, dtMeshTile* prevTile, dtPoly* prevPoly,
				dtPolyRef curRef, dtMeshTile* curTile, dtPoly* curPoly, dtPolyRef nextRef, dtMeshTile* nextTile, dtPoly* nextPoly)
			{
				return dtVdist(pa, pb) * m_areaCost[curPoly->getArea()];
			}
		}
	}
}
